/*
 *------------------------------------------------------------------------------
 * @File      :    af_customer.h
 * @Date      :    2021-8-28
 * @Author    :    lomboswer <lomboswer@lombotech.com>
 * @Brief     :    Source file for MDP(Media Development Platform).
 *
 * Copyright (C) 2020-2021, LomboTech Co.Ltd. All rights reserved.
 *------------------------------------------------------------------------------
 */

#ifndef __AF_CUSTOMER_H__
#define __AF_CUSTOMER_H__

#include "ei_type.h"
#include "ei_comm_3a.h"
#include "ei_af_customer_comm.h"
#include "mi_isp.h"

#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */

typedef struct eiAF_CUSTOMER_CTX_S {
    ISP_AF_PARAM_S          stAfParam;
    EI_U32                  u32AfPriority;
    EI_U32                  u32FrameCnt;
    EI_U32                  u32Reseted;
    ISP_AF_INFO_S           stAfInfo;
    ISP_AF_RESULT_S         stAfResult;
    ISP_DEV                 IspBindDev;

    EI_BOOL                 bAfDrvRegister;
    AF_CUSTOMER_DRIVER_REGISTER_S    stAfRegister;
} AF_CUSTOMER_CTX_S;

extern AF_CUSTOMER_CTX_S g_astAfCustomerCtx[MAX_AF_LIB_NUM];

#define AF_CUSTOMER_GET_CTX(s32Id)           (&g_astAfCustomerCtx[s32Id])

#define AF_CUSTOMER_TRACE(level, fmt, args...)\
    do {\
        if (level != EI_DBG_DEBUG) {\
            EI_TRACE_ISP(level, fmt, ##args);\
        }\
    } while(0)

#define AF_CUSTOMER_CHECK_ID(s32Id)\
    do {\
        if (((s32Id) < 0) || ((s32Id) >= MAX_AF_LIB_NUM)) {\
            AF_CUSTOMER_TRACE(EI_DBG_ERR, "Illegal handle id %d!\n", (s32Id));\
            return EI_FAILURE;\
        }\
    }while(0)

#define AF_CUSTOMER_CHECK_LIB_NAME(acName)\
    do {\
        if (0 != strcmp((acName), EI_AF_CUSTOMER_LIB_NAME))  {\
            AF_CUSTOMER_TRACE(EI_DBG_ERR, "Illegal lib name %s!\n", (acName));\
            return EI_FAILURE;\
        }\
    }while(0)

#define AF_CUSTOMER_CHECK_POINTER(ptr)\
    do {\
        if (EI_NULL == ptr) {\
            AF_CUSTOMER_TRACE(EI_DBG_ERR, "Null Pointer!\n");\
            return EI_FAILURE;\
        }\
    }while(0)

#define AF_CUSTOMER_CHECK_DEV(dev)\
    do {\
        if (((dev) < 0) || ((dev) >= ISP_MAX_DEV_NUM)) {\
            AF_CUSTOMER_TRACE(EI_DBG_ERR, "AE dev %d!\n", dev);\
            return EI_ERR_ISP_ILLEGAL_PARAM;\
        }\
    }while(0)

#define AF_CUSTOMER_ENTER \
    do{ \
        AF_CUSTOMER_TRACE(EI_DBG_DEBUG, "Enter!\n");\
    }while(0)

#define AF_CUSTOMER_EXIT \
    do{ \
        AF_CUSTOMER_TRACE(EI_DBG_DEBUG, "Exit!\n");\
    }while(0)

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */

#endif
